home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17356 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.2 KB  |  169 lines

  1. Path: mail2news.demon.co.uk!idkit.demon.co.uk
  2. From: "Leslie R. Wilk" <Leslie@idkit.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Windows Menu problem - Help requested
  5. Date: Mon, 15 Apr 96 14:07:07 GMT
  6. Organization: Myorganisation
  7. Message-ID: <829577227snz@idkit.demon.co.uk>
  8. Reply-To: Leslie@idkit.demon.co.uk
  9. X-NNTP-Posting-Host: idkit.demon.co.uk
  10. X-Newsreader: Demon Internet Simple News v1.29
  11. X-Mail2News-Path: idkit.demon.co.uk
  12.  
  13.  
  14.  
  15. The 3 Files below are a menu example from SAMS "Teach Yourself c++ in 21 days"
  16.  
  17. They should create a menu titled Les Menu for Windows, with options
  18.  
  19. BUT THEY DONT
  20.  
  21.  
  22. When I run the .exe I get a Dialog Box
  23. TODO: Place Dialog Controls here  OK/CANCEL
  24.  
  25.  
  26. If anyone can please help I would be very grateful.
  27. Thankyou
  28.  
  29.  
  30.  
  31. I am using Microsoft Visual C++ 2.00
  32.  
  33.  
  34.  
  35.                Contents of MENU1.RC
  36.  
  37. #include <afxres.h>
  38. #include "MENU1.H"
  39.  
  40. OPTIONS MENU LOADONCALL MOVEABLE PURE DISCARDABLE
  41. BEGIN
  42.  POPUP "&File"
  43.  BEGIN
  44.   MENUITEM "&New",CM_FILENEW
  45.   MENUITEM "&Open",CM_FILEOPEN
  46.   MENUITEM "&Save",CM_FILESAVE
  47.   MENUITEM "&Save&As",CM_FILESAVEAS
  48.   MENUITEM SEPARATOR
  49.   MENUITEM "E&Exit",CM_EXIT
  50.   END
  51.   POPUP "&Edit"
  52.   BEGIN
  53.     MENUITEM "&Undo",CM_EDITUNDO
  54.     MENUITEM SEPARATOR
  55.     MENUITEM "C&ut",CM_EDITCUT
  56.     MENUITEM "C&opy",CM_EDITCOPY
  57.     MENUITEM "&Paste",CM_EDITPASTE
  58.     POPUP "&Delete"
  59.     BEGIN
  60.       MENUITEM "&Line", CM_EDITDELETE
  61.       MENUITEM "&Block", CM_EDITDELETE_BLOCK
  62.       END
  63.       MENUITEM "&Clear", CM_EDITCLEAR
  64.    END
  65.    MENUITEM "Help", CM_HELP
  66.   END
  67.  
  68.  
  69.  
  70.                 Contents of MENU1.H
  71.  
  72.  
  73.  
  74. #define CM_FILENEW      (WM_USER + 100)
  75. #define CM_FILEOPEN     (WM_USER + 101)
  76. #define CM_FILESAVE        (WM_USER + 102)
  77. #define CM_FILESAVEAS    (WM_USER + 103)
  78. #define CM_EXIT            (WM_USER + 104)
  79. #define CM_EDITUNDO        (WM_USER + 105)
  80. #define CM_EDITCUT        (WM_USER + 106)
  81. #define CM_EDITCOPY        (WM_USER + 107)
  82. #define CM_EDITPASTE    (WM_USER + 108)
  83. #define CM_EDITDELETE    (WM_USER + 109)
  84. #define CM_EDITDELETE_BLOCK  (WM_USER + 110)
  85. #define CM_EDITCLEAR      (WM_USER + 111)
  86. #define CM_HELP            (WM_USER + 112)
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.                    Contents of MENU1.CPP
  94.  
  95.  
  96.  
  97. #include <afxwin.h>
  98. #include "menu1.h"
  99.  
  100. class CAppWindow : public CFrameWnd
  101. {
  102. public:
  103.   CAppWindow ()
  104.   { Create(NULL, " Les Menu for Windows ",
  105.     WS_OVERLAPPEDWINDOW, rectDefault, NULL, "OPTIONS");}
  106. protected:
  107.  
  108. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  109.  
  110. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  111.  
  112. afx_msg void OnExit();
  113.  
  114.  
  115. DECLARE_MESSAGE_MAP()
  116.  
  117. };
  118.  
  119. class CWindowApp : public CWinApp
  120. {
  121. public:
  122.  virtual BOOL InitInstance();
  123. };
  124.  
  125. void CAppWindow::OnLButtonDown(UINT nFlags, CPoint point)
  126. {
  127.  MessageBox("You clicked the left button!",
  128.  "mouse Click Event!",MB_OK);
  129. }
  130.  
  131. void CAppWindow::OnRButtonDown(UINT nFlags,CPoint point)
  132. {
  133.  MessageBeep(0);
  134.  if (MessageBox("Want to close this    application", "Query",
  135.     MB_YESNO | MB_ICONQUESTION) == IDYES)
  136.     SendMessage(WM_CLOSE);
  137. }
  138.  
  139. void CAppWindow::OnExit()
  140. { SendMessage(WM_CLOSE);}
  141.  
  142. BEGIN_MESSAGE_MAP (CAppWindow, CFrameWnd)
  143.  ON_WM_LBUTTONDOWN()
  144.  ON_WM_RBUTTONDOWN()
  145.  ON_COMMAND(CM_EXIT, OnExit)
  146. END_MESSAGE_MAP()
  147.  
  148.  
  149. BOOL CWindowApp::InitInstance()
  150. {
  151.  m_pMainWnd = new CAppWindow();
  152.  m_pMainWnd->ShowWindow(m_nCmdShow);
  153.  m_pMainWnd->UpdateWindow();
  154.  return TRUE;
  155. }
  156.  
  157.  
  158. CWindowApp WindowApp;
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. -- 
  168. Leslie R. Wilk
  169.